Fix Maven build shortcut (Alt+Shift+X+M) not working since Eclipse 2023-09 #2049
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The Maven build shortcut (Alt+Shift+X+M) stopped working in Eclipse 2023-09 and later versions, although it worked correctly in Eclipse 2023-06. Users could no longer trigger Maven builds using the keyboard shortcut, forcing them to use context menus or the Run menu instead.
Root Cause
The
plugin.xmldefined commands and keybindings for Maven shortcuts, but there were no handlers registered to execute these commands. Without handlers, Eclipse had no code to run when users pressed the keyboard shortcuts, causing them to silently fail.Solution
This PR adds a new
MavenLaunchShortcutHandlerthat implements the command handlers and registers them inplugin.xml. The handler provides behavior similar to Eclipse's "Re-run last launch" (Ctrl+F11), but specifically for Maven builds:Re-runs the most recent Maven launch: When Alt+Shift+X+M is pressed, the handler searches the launch history for the most recently executed Maven build configuration and re-launches it.
Falls back to dialog: If no previous Maven launch exists in the history, it opens the Maven launch configuration dialog to create a new one.
Supports goal-specific shortcuts: The implementation also enables keyboard shortcuts for specific Maven lifecycle goals (clean, install, test, generate-sources).
Changes
New File:
MavenLaunchShortcutHandler.javaAbstractHandlerto handle Eclipse command executionIExecutableExtensionto support parameterized handlers (e.g.,clean,install, etc.)ExecutePomActionfor dialog-based launches when neededUpdated:
plugin.xmlorg.eclipse.m2e.core.pomFileAction.run(general Maven build - Alt+Shift+X+M)org.eclipse.m2e.actions.LifeCycleInstall.runorg.eclipse.m2e.actions.LifeCycleClean.runorg.eclipse.m2e.actions.LifeCycleTest.runorg.eclipse.m2e.actions.LifeCycleGenerateSources.runTesting
The implementation can be tested by:
Fixes #[issue number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cbi.eclipse.orgcurl -o org/fusesource/jansi/internal/native/Mac/arm64/libjansi.jnilib -F file=@org/fusesource/jansi/internal/native/Mac/arm64/libjansi.jnilib-tosign REDACTED(dns block)curl -o org/fusesource/jansi/internal/native/Mac/x86/libjansi.jnilib -F file=@org/fusesource/jansi/internal/native/Mac/x86/libjansi.jnilib-tosign REDACTED(dns block)curl -o org/fusesource/jansi/internal/native/Mac/x86_64/libjansi.jnilib -F file=@org/fusesource/jansi/internal/native/Mac/x86_64/libjansi.jnilib-tosign REDACTED(dns block)repo.eclipse.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/m2e-core/m2e-core org.codehaus.plexus.classworlds.launcher.Launcher clean install -DskipTests -T 1C(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/m2e-core/m2e-core org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip.exec -Dlicense.skip=true -Drat.skip=true -Dspotless.check.skip=true -s /home/REDACTED/work/m2e-core/.codeql-scratch/dbs/java/working/settings.xml com.github.ferstl:depgraph-maven-plugin:4.0.3-CodeQL:graph -B -DclasspathScopes=compile -DoutputDirectory=/home/REDACTED/work/m2e-core/.codeql-scratch/dbs/java/working/java-standalone-dependency-graph2342849966494729795/${project.groupId}/${project.artifactId} -DgraphFormat=json -Dmaven.ext.class.path=/opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/java/tools/java-buildless-maven-plugin.jar(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #1618
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.